﻿using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Sumc.Client.ModernUI.Extensions
{
    public static class ObservableCollectionExtensions
    {
        public static void FillCollection<T>(this ObservableCollection<T> collection, IEnumerable<T> items)
        {
            collection.Clear();

            if (items != null)
            {
                foreach (var item in items)
                {
                    collection.Add(item);
                }
            }
        }

        public static void FillCollection<T>(this ObservableCollection<T> collection, params T[] items)
        {
            collection.Clear();

            foreach (var item in items)
            {
                collection.Add(item);
            }
        }

        public static void AddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> items)
        {
            foreach (var item in items)
            {
                collection.Add(item);
            }
        }
    }
}
